package com.rop.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.rop.model.system.SysLoginLog;
import com.rop.model.vo.SysLoginLogQueryVo;
import com.rop.result.Result;
import com.rop.system.service.SysLoginLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Title: SysLoginLogController
 * @Author Rop
 * @Date 2023/5/16 16:16
 * @description: 登录日志
 */

@Api(tags = "登录日志接口")
@RestController
@RequestMapping("admin/system/sysLoginLog")
public class SysLoginLogController {

    @Autowired
    private SysLoginLogService sysLoginLogService;

    /**
     * 分页列表查询
     * @param page 页数
     * @param limit ""
     * @param sysLoginLogQueryVo vo
     * @return ""
     */
    @ApiOperation("获取分页列表")
    @GetMapping("{page}/{limit}")
    public Result<IPage<SysLoginLog>> index(@PathVariable Long page,
                                            @PathVariable Long limit,
                                            SysLoginLogQueryVo sysLoginLogQueryVo) {
        IPage<SysLoginLog> pageModel = sysLoginLogService.selectPage(page, limit, sysLoginLogQueryVo);
        return Result.ok(pageModel);
    }

    @ApiOperation("根据id获取登录日志")
    @GetMapping("get/{id}")
    public Result<SysLoginLog> get(@PathVariable Long id) {
        SysLoginLog sysLoginLog = sysLoginLogService.getById(id);
        return Result.ok(sysLoginLog);
    }
}
